<?php
/* [DoYouHaoBaby!] (C)Dianniu From 2010.
   this($)*/

!defined('DYHB_PATH') && exit;

class TemplateGtkGladeWidgetCompiler_GtkScrolledWindow extends TemplateGtkGladeWidgetCompiler_GtkContainer{

	protected function compileCreateWidget_(TemplateGtkGladeWidget $oObject){
		$sWidgetClass=$oObject->getWidgetClass();
		$sVariableName='$'.TemplateGtkGlade::getWidgetVariableName($oObject);
		$sCompiled="\t\t{$sVariableName}=new {$sWidgetClass}();";
		if(($sHscrollbarPolicy=$oObject->getProperty('hscrollbar_policy'))===null){$sHscrollbarPolicy='GTK_POLICY_ALWAYS';}// 横竖滚动条 显示策略
		if(($sVscrollbarPolicy=$oObject->getProperty('vscrollbar_policy'))===null){$sVscrollbarPolicy='GTK_POLICY_ALWAYS';}
		$sHscrollbarPolicy=str_replace('GTK_','Gtk::',$sHscrollbarPolicy);
		$sVscrollbarPolicy=str_replace('GTK_','Gtk::',$sVscrollbarPolicy);
		$sCompiled.="\t\t{$sVariableName}->set_policy({$sHscrollbarPolicy},{$sVscrollbarPolicy});";
		if(TemplateGtkGladeObj::nodeTextToValue($oObject->getProperty('window_placement_set'))){// 窗口放置位置
			if($sValue=$oObject->getProperty('window_placement')){
				$sValue=str_replace('GTK_','Gtk::',$sValue);
				$sCompiled.= "\t\t{$sVariableName}->set_placement({$sValue});";
			}
		}
		if($sValue=$oObject->getProperty('shadow_type')){// 阴影类型
			$sValue=str_replace('GTK_','Gtk::',$sValue);
			$sCompiled.= "\t\t{$sVariableName}->set_shadow_type({$sValue});";
		}
		return $sCompiled;
	}

	protected function compileChildWidgetPacking_(TemplateGtkGladeWidget $oParentWidget,TemplateGtkGladeWidget $oChildWidget, TemplateGtkGladeWidgetPacking $oPacking){
		$sParentVariableName='$'.TemplateGtkGlade::getWidgetVariableName($oParentWidget);// 父/子 窗体变量名
		$sChildWidgetVariableName='$'.TemplateGtkGlade::getWidgetVariableName($oChildWidget);
		$sChildWidgetName=$oChildWidget->getWidgetId();// 子窗体名
		$sCompiled="\t\t{$sChildWidgetVariableName}=\$this->getWidget('{$sChildWidgetName}',\$arrObjectForSignal);";
		$sCompiled.="\t\t{$sParentVariableName}->add_with_viewport({$sChildWidgetVariableName});";
		return $sCompiled;
	}

	static public function regToProcessorManager(ITemplateObjProcessorManager $oManager){
		$oManager->regProcessor(str_replace('TemplateGtkGladeWidgetCompiler_','',__CLASS__),__CLASS__);
	}

}
